package com.access.boot.autoconfigure.apisdk.aop;

import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;

/**
 * @author Yangzhen
 * @date 2022/6/2 17:03
 * @since 1.0.0
 */
public class Demo {

    public static void main(String[] args) {
        Map<String, Object> map = new HashMap<>();
        DefaultProxyFactory proxyFactory = new DefaultProxyFactory(map);

        proxyFactory.addAdvice(new MethodBeforeAdvice() {
            @Override
            public void before(Method method, Object[] args, Object target) throws Throwable {
                if ("put".equals(method.getName()) && args.length == 2) {
                    System.out.printf("[MethodBeforeAdvice] 当前存放是 Key: %s , Value : %s ，" +
                            "代理对象：%s\n", args[0], args[1], target);
                }
            }
        });

        Map<String, Object> proxy = proxyFactory.getProxy();
        proxy.put("A", 1);
        proxy.put("B", 2);
    }
}
